#include <graphics.h>
#include <conio.h>
#include <math.h>
#define width 640
#define height 480
void main(){
initgraph(width,height);
int ballx,bally;
ballx=width/2;
bally=height/2;
int ballvx,ballvy;
ballvy=1;
ballvx=1;
int radius=20;
while(1){
ballx=ballx+ballvx;
bally=bally+ballvy;
if(ballx<=radius||ballx>=width-radius){
ballvx=-ballvx;
}
if(bally<=radius||bally>=height-radius){
ballvy=-ballvy;
}
setfillcolor(RED);
fillcircle(ballx,bally,radius);
Sleep(3);
FlushBatchDraw();
}
EndBatchDraw();
_getch();
closegraph();
}